package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 护理计划
 * @Description: TODO
 * @DateTime: 2024/6/11 9:41
 **/
@RestController
@RequestMapping("/nursing/plan")
@Api(tags = "护理计划相关接口")
public class NursingPlanController extends BaseController{

    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping
    @ApiOperation(value = "护理计划查询列表")
    public ResponseResult<List<NursingPlanVo>> queryList(){
        return success(nursingPlanService.queryList());
    }

    @PostMapping
    @ApiOperation("新增护理计划")
    public ResponseResult addNursingPlan(@RequestBody NursingPlanDto dto){
        nursingPlanService.addNursingPlan(dto);
        return success();
    }

    @GetMapping("/search")
    @ApiOperation("条件分页查询护理计划")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name",value = "护理项目名称"),
            @ApiImplicitParam(name = "pageNum",value = "当前页码",defaultValue = "1"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",defaultValue = "5"),
            @ApiImplicitParam(name = "status",value = "状态(0:禁用,1:启用)")
    })
    public ResponseResult findPage(String name,Integer pageNum,Integer pageSize,Integer status){
        PageResponse result = nursingPlanService.findPage(name,pageNum,pageSize,status);
        return success(result);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理计划")
    public ResponseResult findById(@PathVariable Long id){
        NursingPlanVo vo = nursingPlanService.findById(id);
        return success(vo);
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult enableOrDisable(
            @ApiParam(value = "计划ID", required = true) @PathVariable Long id,
            @ApiParam(value = "计划状态", required = true) @PathVariable Integer status) {
        nursingPlanService.enableOrDisable(id, status);
        return success();
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deletePlan(@PathVariable Long id) {
        nursingPlanService.deletePlan(id);
        return success();
    }

    @PutMapping
    @ApiOperation("编辑护理计划")
    public ResponseResult updatenursingPlan(@RequestBody NursingPlanDto dto){
        nursingPlanService.updatenursingPlan(dto);
        return success();
    }
}
